package com.sanyang.pda.adapter;

import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.sanyang.pda.bean.MovementLogBean;
import com.wangshen.base.ui.mvp.base.adapter.BaseAdapter;
import com.wangshen.projectbase.R;

import java.util.List;

public class MovementLogAdapter extends BaseAdapter<MovementLogBean> {
    public MovementLogAdapter(int layoutResId, @Nullable List<MovementLogBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MovementLogBean item) {
        super.convert(helper, item);
        helper.setText(R.id.tv_move_order,item.getShiftNo());
        helper.setText(R.id.tv_operating_personnel,item.getShiftBy());
        helper.setText(R.id.tv_moveout_location,item.getStoragebinOut());
        helper.setText(R.id.tv_movein_location,item.getStoragebinIn()+"");
        helper.setText(R.id.tv_tray,item.getPallet());
        if (item.getShiftStatus() == 10){
            helper.setText(R.id.tv_states,getContext().getString(R.string.daiyiru));
        }else {
            helper.setText(R.id.tv_states,getContext().getString(R.string.yiwancheng));
        }
        helper.setText(R.id.tv_moveout_time,item.getShiftTime());
        CheckBox checkBox=helper.getView(R.id.cb_open);
        RecyclerView linearLayout=helper.getView(R.id.rv_list);
        MovementLogListAdapter adapter=new MovementLogListAdapter(R.layout.item_movement_log_list,item.getWarehouseStockArticleVoList());
        linearLayout.setLayoutManager(new LinearLayoutManager(getContext()));
        linearLayout.setAdapter(adapter);
        checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked){
                    linearLayout.setVisibility(View.VISIBLE);
                }else {
                    linearLayout.setVisibility(View.GONE);
                }
            }
        });
    }
}
